<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

    <style type="text/css" media="screen">
        @import url("<c:url value="/resources/dojo/resources/dojo.css"/>");
        @import url("<c:url value="/resources/dijit/themes/tundra/tundra.css"/>");
        @import url("<c:url value="/static/styles/finance.css"/>");
    </style>

    <script djconfig="parseOnLoad: true" src="<c:url value="/resources/dojo/dojo.js"/>" type="text/javascript"></script>
    <script type="text/javascript" src="<c:url value="/resources/spring/Spring.js" />"></script>
    <script type="text/javascript" src="<c:url value="/resources/spring/Spring-Dojo.js" />"></script>
    <script type="text/javascript">dojo.require("dojo.parser");</script>
    <title>Spring Finance</title>

</head>

<body class="tundra spring">

<div id="wrap">

    <div id="menu">
        <%@ include file="/WEB-INF/jsp/menu.jsp" %>
    </div>
    <div id="main">
        <div id="body">


            <script type="text/javascript">dojo.require("dijit.TitlePane");</script>

            <div dojoType="dijit.TitlePane" style="width: 100%" title="Create New Loan Product">
                <form:form modelAttribute="loan">
                    <div>
                        <label for="name_loan">Name:</label>
                        <form:input cssStyle="width:250px" maxlength="30" path="name" id="name_loan" size="30"/>
                        <form:errors path="name" cssClass="errors"/>
                        <script type="text/javascript">Spring.addDecoration(new Spring.ElementDecoration({elementId : "name_loan", widgetType : "dijit.form.ValidationTextBox", widgetAttrs : {promptMessage: "Enter Name", required : true}})); </script>
                    </div>
                    <br/>

                    <div>
                        <label for="description_loan">Description:</label>
                        <form:textarea cssStyle="width:250px;height:15em" id="description_loan" path="description"/>
                        <form:errors path="description" cssClass="errors"/>
                        <script type="text/javascript">Spring.addDecoration(new Spring.ElementDecoration({elementId : "description_loan", widgetType: "dijit.form.Textarea", widgetAttrs: {value: ""}})); </script>
                        <script type="text/javascript">Spring.addDecoration(new Spring.ElementDecoration({elementId : "description_loan", widgetType : "dijit.form.ValidationTextBox", widgetAttrs : {promptMessage: "Enter Description", required : false}})); </script>
                    </div>
                    <br/>

                    <div>
                        <label for="managementFee_loan">Management Fee:</label>
                        <form:input cssStyle="width:250px" maxlength="30" path="managementFee" id="managementFee_loan"
                                    size="30"/>
                        <form:errors path="managementFee" cssClass="errors"/>
                        <script type="text/javascript">Spring.addDecoration(new Spring.ElementDecoration({elementId : "managementFee_loan", widgetType : "dijit.form.ValidationTextBox", widgetAttrs : {invalidMessage: "Enter Management Fee (numbers only)", regExp: "-?[0-9]*\.[0-9]*", required : false}})); </script>
                    </div>
                    <br/>

                    <div>
                        <label for="interest_loan">Interest:</label>
                        <form:input cssStyle="width:250px" maxlength="30" path="interest" id="interest_loan" size="30"/>
                        <form:errors path="interest" cssClass="errors"/>
                        <script type="text/javascript">Spring.addDecoration(new Spring.ElementDecoration({elementId : "interest_loan", widgetType : "dijit.form.ValidationTextBox", widgetAttrs : {invalidMessage: "Enter Distribution (numbers only)", regExp: "-?[0-9]*\.[0-9]*", required : false}})); </script>
                    </div>
                    <br/>

                    <div>
                        <label for="principal_loan">Principal:</label>
                        <form:input cssStyle="width:250px" maxlength="30" path="principal" id="principal_loan"
                                    size="30"/>
                        <form:errors path="principal" cssClass="errors"/>
                        <script type="text/javascript">Spring.addDecoration(new Spring.ElementDecoration({elementId : "principal_loan", widgetType : "dijit.form.ValidationTextBox", widgetAttrs : {invalidMessage: "Enter Distribution (numbers only)", regExp: "-?[0-9]*\.[0-9]*", required : false}})); </script>
                    </div>
                    <br/>
                    <c:if test="${not empty lenders}">
                        <div>
                            <label for="lenders">Lenders:</label>
                            <form:select cssStyle="width:250px" path="lenders">
                                <form:options itemValue="id" items="${lenders}"/>
                            </form:select>
                            <form:errors path="lenders" cssClass="errors"/>
                            <script type="text/javascript">Spring.addDecoration(new Spring.ElementDecoration({elementId : "lenders", widgetType: "dijit.form.MultiSelect", widgetAttrs : {hasDownArrow : true}})); </script>
                        </div>
                        <br/>
                    </c:if>
                    <div class="submit buttonGroup">
                        <input type="submit" name="_eventId_cancel" value="Cancel"/>&#160;
                        <input type="submit" id="product" name="_eventId_product" value="Add Another Product"/>&#160;
                        <input type="submit" id="account" name="_eventId_account" value="Proceed"/>&#160;
                        <script type="text/javascript">
                            Spring.addDecoration(new Spring.ValidateAllDecoration({elementId:'account', event:'onclick'}));
                            Spring.addDecoration(new Spring.ValidateAllDecoration({elementId:'product', event:'onclick'}));
                        </script>

                    </div>
                </form:form>
            </div>
        </div>
        <table class="footer">
            <tr>
                <td><a href="<c:url value="/" />">Home</a></td>
                <td align="right"><a href="http://stsmedia.net" alt="StSMedia.net">StSMedia.net</a></td>
            </tr>
        </table>

    </div>
</div>
</body>

</html>